<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<body>
    <ui:composition template="../templates/template.xhtml">
    <ui:define name="titre">Paramétrage::Gestion des classes</ui:define>
    <ui:define name="zone1">
    	<div class="form">
    		<h:form>
    			<h:messages id="messages" warnClass="msgWarn" errorClass="msgError" infoClass="msgInfo"
							globalOnly="true" styleClass="borderBleu messageBloc"/>
				<div  class="borderBleu">
						<h:panelGroup rendered="#{fn:length(ParametrageControleur.modele.classes) > 0}"  >
							<div class="titre">
								<h:outputLabel value="Liste des classes" />
							</div>
						</h:panelGroup>
						<div id="formResult">
							<rich:dataTable id="classes" value="#{ParametrageControleur.modele.classes}"	
		       	 				var="classe" rendered="#{fn:length(ParametrageControleur.modele.classes) > 0}" rows="10">
					        	<rich:column >
					        		<f:facet name="header">
					        			<h:outputText 	value="Classe" />
					        		</f:facet>
					        		<h:outputText value="#{classe.libelle}" />
					        	</rich:column>
					        	<rich:column >
					        		<f:facet name="header">
					        			<h:outputText 	value="Nombre de groupe" />
					        		</f:facet>
					        		<h:outputText value="#{classe.nombregroupe}" />
					        	</rich:column>
					        	<rich:column >
					        		<f:facet name="header">
					        			<h:outputText 	value="Capacité max." />
					        		</f:facet>
					        		<h:outputText value="#{classe.taille}" />
					        	</rich:column>
					        	<rich:column>
					        		<f:facet name="header">
					        			<h:outputText 	value="" />
					        		</f:facet>
					        		<a4j:commandLink styleClass="btnTableau" value="modifier" execute="@this" render="panelmodification"  
					        			oncomplete="#{rich:component('panelmodification')}.show();">
					        			<f:setPropertyActionListener target="#{ParametrageControleur.modele.classe}" value="#{classe}" />
					        		</a4j:commandLink>
					        	</rich:column>
		       				</rich:dataTable>
						</div>
						<div id="boutons">         
			                <a4j:commandLink styleClass="btValider" value="Créer une classe" execute="@this"  
									oncomplete="#{rich:component('panelajout')}.show();">
			                </a4j:commandLink>
                		</div>
						
				</div>
				<!-- popup ajout classe -->
				 <rich:popupPanel modal="true" id="panelajout" domElementAttachment="parent" width="500" height="200">
				 	<div  class="borderBleu">
				 		<div class="titre">
								<h:outputLabel value="Nouvelle classe" />
						</div>
				 	</div>
				 	<h:panelGrid columns="2" columnClasses="tabline1, tabline2" styleClass="spanelTable">
				 		<h:panelGroup>
				 			<h:outputLabel value="Libelle" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id="libelleajout" value="#{ParametrageControleur.modele.classe.libelle}" required="true"/>
                            <h:message id="libelleajoutmsg" for="libelleajout" errorClass="msgError"/>
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:outputLabel value="Nombre de groupe" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id ="nombreajout" value="#{ParametrageControleur.modele.classe.nombregroupe}" 	required="true" />
                            <h:message id="nombreajoutmsg" for="nombreajout" errorClass="msgError"/>
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:outputLabel value="Capacité max des groupes" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id="tailleajout" value="#{ParametrageControleur.modele.classe.taille}"	required="true" />
                            <h:message id="tailleajoutmsg" for="tailleajout" errorClass="msgError"/>
				 		</h:panelGroup>
				 	</h:panelGrid>
                    <div id="boutons">         
	                     <a4j:commandLink styleClass="btValider" value="Valider" render ="classes" execute="panelajout" action="#{ParametrageControleur.ajouterClasse}"
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('panelajout')}.hide();}">
	                     </a4j:commandLink>
	                     <a4j:commandLink styleClass="btAnnuler" value="Annuler" onclick="#{rich:component('panelajout')}.hide(); return false;" />
                    </div>    
            	 </rich:popupPanel>
            	 <!-- fin popup ajout classe -->
            	 <!--  popup maj classe -->
            	 <rich:popupPanel modal="true"  id="panelmodification" domElementAttachment="parent"
		     			width="500" height="200">
		     		<div  class="borderBleu">
				 		<div class="titre">
								<h:outputLabel value="Mise à jour de classe #{ParametrageControleur.modele.classe.libelle}" />
						</div>
				 	</div>
				 	<h:panelGrid columns="2" columnClasses="tabline1, tabline2" styleClass="spanelTable">
				 		<h:panelGroup>
				 			<h:outputLabel value="Libelle" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id="libelle" value="#{ParametrageControleur.modele.classe.libelle}" required="true" />
                            <h:message id="libellemsg" for="libelle" errorClass="msgError"/>
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:outputLabel value="Nombre de groupe" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id ="nombre" value="#{ParametrageControleur.modele.classe.nombregroupe}" 	required="true" />
                            <h:message id="nombremsg" for="nombre" errorClass="msgError"/>
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:outputLabel value="Capacité max des groupes" />
				 		</h:panelGroup>
				 		<h:panelGroup>
				 			<h:inputText id="taille" value="#{ParametrageControleur.modele.classe.taille}" 	required="true" />
                            <h:message id="taillemsg" for="taille" errorClass="msgError"/>
				 		</h:panelGroup>
				 	</h:panelGrid>
                    <div align="left">         
	                     <a4j:commandLink styleClass="btValider" value="Valider" render ="classes" execute="panelmodification" action="#{ParametrageControleur.modifierClasse}"
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('panelmodification')}.hide();}">
	                     </a4j:commandLink>
	                      <a4j:commandLink  styleClass="btAnnuler" value="Annuler" onclick="#{rich:component('panelmodification')}.hide(); return false;" />
                    </div>    
               </rich:popupPanel>
    		</h:form>
    	</div>
    </ui:define>
</ui:composition>
</body>
</html>